package com.schoolcardinfo.biz.impl;

import java.util.ArrayList;
import java.util.List;

import com.schoolcardinfo.beans.RechargeInfo;
import com.schoolcardinfo.biz.IRechargeInfoBiz;
import com.schoolcardinfo.dao.DBHelper;

public class RechargeInfoBizImpl implements IRechargeInfoBiz{
	private DBHelper db=new DBHelper();
	@Override
	public int addRechargeInfo(RechargeInfo ri) {
		String sql="insert into rechargeInfo values(null,date_format(now(),'%Y-%m-%d'),?,?,default)";
		List<Object> params=new ArrayList<Object>();
		params.add(ri.getRmoney());
		params.add(ri.getSid());
		int result=db.update(sql, params);
		return result;
	}

	@Override
	public List<RechargeInfo> selectRechargeInfo(int sid) {
		String sql="";
		if(sid==0){
			sql="select * from rechargeInfo";
		}else{
			sql="select * from rechargeInfo where sid="+sid;
		}
		List<RechargeInfo> list=db.find(sql, null, RechargeInfo.class);
		if(list.size()>0){
			return list;
		}else{
			return null;
		}
	}

	@Override
	public List<RechargeInfo> selectRecStatus(int status) {
		String sql="select * from rechargeInfo where rstatus="+status;
		List<RechargeInfo> list=db.find(sql, null, RechargeInfo.class);
		if(list.size()>0){
			return list;
		}else{
			return null;
		}
	}

}
